﻿/********************************************************************
	created:	2011-8-11   4:51
	author:		Lifan Su
	
	purpose:	C++1x compliant nullptr implement
*********************************************************************/

#ifndef NULLPTR_HPP
#define NULLPTR_HPP

#if defined _MSC_VER

    #if _MSC_VER == 1600
        //  In this version, nullptr is a keyword, and no need to add
    #else
        //  Taken from "More Effective C++" by Scott Meyer
        //  Some adopts to meet standard
        namespace std {
            class nullptr_t 
            {
            public:
                template<class T>
                inline operator T*() const // convertible to any type of null non-member pointer...
                { return 0; }
        
                template<class C, class T>
                inline operator T C::*() const   // or any type of null member pointer...
                { return 0; }
        
            private:
                void operator&() const;  // Can't take address of nullptr
        
            };
        }
        
        // It is a const object...
        const nullptr_t nullptr = {};
    #endif

#else
#error "Unsupported platform"
#endif

#endif // NULLPTR_HPP